﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucArticleCategory.ascx.cs"
    Inherits="SES.CMS.AdminCP.PageUC.ucArticleCategory" %>
<%@ Register Assembly="DevExpress.Web.v9.2, Version=9.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dxpc" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v9.2, Version=9.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function OnClientPasteHtml(sender, args) {
            var commandName = args.get_commandName();
            var value = args.get_value();
            if (commandName == "ImageManager") {
                //See if an img has an alt tag set
                var div = document.createElement("DIV");
                //Do not use div.innerHTML as in IE this would cause the image's src or the link's href to be converted to absolute path.
                //This is a severe IE quirk.
                Telerik.Web.UI.Editor.Utils.setElementInnerHtml(div, value);
                //Now check if there is alt attribute
                var img = div.firstChild;
                //alert(div.innerHTML);

                //Set new content to be pasted into the editor

                if (!!img.alt) {
                    var newInner = "<center>";
                    newInner = newInner + "<img src='" + img.src + "' alt='" + img.alt + "'/></center><center>";
                    newInner = newInner + img.alt + "</center>";

                    args.set_value(newInner);
                }
                else {
                    var newInner = "<center><img src='" + img.src + "' alt='Dang Viet jsc'/></center><br/>";

                    args.set_value(newInner);
                }

            }
        }
    </script>
</telerik:RadCodeBlock>
<script type="text/javascript">
    function SelectAndClosePopup(value) {
        cbParent.SetValue(value);
        pcParent.Hide();
    }
</script>
<h2>
    Cập nhật Danh mục Tin tức</h2>
<table width="100%" border="1">
    <tr>
        <td class="style8" style="width:150px;">
            Tiêu đề:
        </td>
        <td class="style9">
        <div style="float:left; width:300px;">
            <asp:TextBox ID="txtTitle" runat="server" Width="273px" ValidationGroup="submitGrp"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTitle"
                ErrorMessage="*" ValidationGroup="submitGrp"></asp:RequiredFieldValidator>
          </div>   <div style="float:left; width:300px;">
                <asp:RadioButton ID="rdoCT" GroupName="type" Text="Trang nội dung" runat="server" Checked="true" />
                <asp:RadioButton ID="rdoTT" GroupName="type" Text="Trang danh mục tin tức" runat="server" />
                <asp:RadioButton ID="rdoSVD" GroupName="type" Text="Dịch vụ chi tiết" runat="server" Visible="false" />
                <asp:RadioButton ID="rdoNW" runat="server" GroupName="type" Text="Tin tức" Visible="false" />
            </div>
        </td>
    </tr>
    <tr>
        <td class="style8">
            Danh mục:
        </td>
        <td class="style9">
            <div style="float: left; vertical-align: middle;">
                <dxe:ASPxComboBox ID="cboParent" ClientEnabled="false" ClientInstanceName="cbParent"
                    runat="server" Height="16px" Width="143px">
                </dxe:ASPxComboBox>
            </div>
            <div style="float: left; margin-left: 5px; vertical-align: middle;">
                <dxe:ASPxButton ID="btnSelectParent" runat="server" Text="Chọn">
                    <ClientSideEvents Click="function(s, e) { pcParent.Show();}" />
                </dxe:ASPxButton>
            </div>
            <div style="float: left; margin-left: 5px; vertical-align: middle;">
                <asp:CheckBox ID="chkIsTop" runat="server" Checked="true" />Danh mục cấp cao nhất</div>
        </td>
    </tr>
    <tr>
        <td class="style8">
            Hình ảnh:
        </td>
        <td class="style9">
            <asp:FileUpload ID="fuImage" runat="server" />
            &nbsp;
            <asp:HyperLink ID="hplImage" runat="server" Target="_blank" Visible="False">[Xem 
            ảnh]</asp:HyperLink>
        </td>
    </tr>
    <tr style="display:none;">
        <td class="style8">
            Mô tả:
        </td>
        <td>
            <CKEditor:CKEditorControl ID="txtDescription" runat="server">
            </CKEditor:CKEditorControl>
        </td>
    </tr>
    <tr>
        <td class="style8">
            Nội dung chi tiết:
        </td>
        <td>
            <CKEditor:CKEditorControl ID="txtDetailContent" runat="server" Visible="false">
            </CKEditor:CKEditorControl>
             <telerik:RadEditor ID="txtDetail" runat="server" OnClientPasteHtml="OnClientPasteHtml"
                            DialogHandlerUrl="~/Telerik.Web.UI.DialogHandler.axd" Width="99%" Height="700px">
                            <ImageManager MaxUploadFileSize="1024000000" ViewMode="Grid" DeletePaths="~/Media/"
                                UploadPaths="~/Media/" ViewPaths="~/Media/"></ImageManager>
                        </telerik:RadEditor>
        </td>
    </tr>
    <tr>
        <td class="style8">
           <%-- Hiển thị:--%>
           Số thứ tự
        </td>
        <td class="style4">
            <div style="float: left; vertical-align: middle;">
                &nbsp;
                <asp:CheckBox ID="chkIsHomePage" runat="server" />
                Hiện ở trang chủ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:CheckBox ID="chkIsPublish" runat="server" Visible="false" />
               <%-- Ẩn đi--%> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Số
                thứ tự:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
            <div style="float: left; vertical-align: middle;">
                <asp:TextBox ID="txtOrderID" runat="server" Width="68px" ValidationGroup="submitGrp" Text="0"></asp:TextBox>
            </div>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtOrderID"
                ErrorMessage="*** Cần nhập số thứ tự" ValidationGroup="submitGrp"></asp:RequiredFieldValidator>
                   <asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Nhập số(Giá trị từ 0~1000)"
                ForeColor="Red" ControlToValidate="txtOrderID" Type="Integer" MinimumValue="0"
                MaximumValue="1000"></asp:RangeValidator>
        </td>
    </tr>
    <tr>
        <td class="style8">
            &nbsp;
        </td>
        <td class="style4">
            <asp:Button ID="btnSave" runat="server" Text="Lưu" OnClick="btnSave_Click" ValidationGroup="submitGrp" />
            <asp:Button ID="btnReset" runat="server" Text="Hủy" />
        </td>
    </tr>
</table>
<dxpc:ASPxPopupControl ID="pcParent" runat="server" ClientInstanceName="pcParent"
    CloseAction="CloseButton" ContentUrl="~/AdminCP/ListCategory.aspx" HeaderText="Chọn danh mục mẹ"
    PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" Height="336px"
    Width="699px">
    <ContentCollection>
        <dxpc:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
        </dxpc:PopupControlContentControl>
    </ContentCollection>
</dxpc:ASPxPopupControl>
